<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping as ORM;
use App\Base\Annotation\Common;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ODM\Document(repositoryClass="App\Repository\GiftLogRepository")
 * @ORM\Entity()
 */
class GiftLog
{
    /**
     * @Common(cnName="#",editType="text",listType="text")
     * @ODM\Id(strategy="INCREMENT")
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @Groups({"app"})
     */
    private $id;

//    /**
//     * @Common(cnName="用户",editType="entity",listType="text")
//     * @ODM\ReferenceOne(targetDocument="App\Entity\User", inversedBy="giftLogs",storeAs=ClassMetadata::REFERENCE_STORE_AS_DB_REF)
//     * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="giftLogs")
//     * @ORM\JoinColumn(nullable=false)
//     * @Groups({"app"})
//     */
//    private $user;

//    /**
//     * @Common(cnName="礼品",editType="entity",listType="text")
//     * @ODM\ReferenceOne(targetDocument="App\Entity\Gift", inversedBy="logs")
//     * @ORM\ManyToOne(targetEntity="App\Entity\Gift", inversedBy="logs")
//     * @ORM\JoinColumn(nullable=false)
//     * @Groups({"app"})
//     */
//    private $gift;

    /**
     * @Common(cnName="用户",editType="entity",listType="text")
     * @ODM\EmbedOne(targetDocument="App\Entity\User")
     * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="giftLogs")
     * @ORM\JoinColumn(nullable=false)
     * @Groups({"app"})
     */
    private $user;

    /**
     * @Common(cnName="礼品",editType="entity",listType="text")
     * @ODM\EmbedOne(targetDocument="App\Entity\Gift")
     * @ORM\ManyToOne(targetEntity="App\Entity\Gift", inversedBy="logs")
     * @ORM\JoinColumn(nullable=false)
     * @Groups({"app"})
     */
    private $gift;

    /**
     * @Common(cnName="领取时间",editType="datetime",listType="text")
     * @ODM\Field( type="date", nullable=true)
     * @ORM\Column(type="datetime", nullable=true)
     * @Groups({"app"})
     */
    private $createAt;

    /**
     * 领取状态
     *      1：兑换未领取
     *      2：已领取
     * @Common(cnName="状态",editType="datetime",listType="text")
     * @ODM\Field( type="raw", nullable=true)
     * @Groups({"app"})
     * @ORM\Column(type="integer", nullable=true)
     */
    private $status;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getUser(): ?User
    {
        return $this->user;
    }

    public function setUser(?User $user): self
    {
        $this->user = $user;

        return $this;
    }

    public function getGift(): ?Gift
    {
        return $this->gift;
    }

    public function setGift(?Gift $gift): self
    {
        $this->gift = $gift;

        return $this;
    }

    public function getCreateAt(): ?\DateTimeInterface
    {
        return $this->createAt;
    }

    public function setCreateAt(?\DateTimeInterface $createAt): self
    {
        $this->createAt = $createAt;

        return $this;
    }

    public function getStatus(): ?int
    {
        return $this->status;
    }

    public function setStatus(?int $status): self
    {
        $this->status = $status;

        return $this;
    }
}
